import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'wonders/config/navigator_monitor.dart';
import 'wonders/framework.dart';
import 'local/config/context.dart';
import 'local/model/app_model.dart';
import 'local/pages/index.dart';
import 'local/data/request_token_interceptor.dart';
import 'package:camera/camera.dart';
void main() async {
  await initAsync();
  runApp(new MainPage());
}
initAsync() async{
  //获取相机信息
  cameras = await availableCameras();
  //添加拦截器
  HttpUtils().addInterceptor(new TokenInterceptor());
}

class MainPage extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
   final app = ScopedModel(
     model: AppModel(cameras: cameras),
     child: new MaterialApp(
       locale: Locale("zh"),
       localizationsDelegates: [
         GlobalMaterialLocalizations.delegate,
         GlobalWidgetsLocalizations.delegate
       ],
       supportedLocales: [
         Locale("zh", "CH"),
         Locale("en", "US"),
       ],
       debugShowCheckedModeBanner: false,
       title: "OneApp",
       theme: App.themeData,
       home: SplashPage(),
       onGenerateRoute: App.router.generator,
       navigatorObservers: [
         NavigatorMonitor(),
       ],
     ),
   );
   return app;
  }
}
List<CameraDescription> cameras;